package com.jk.mapper;

import com.jk.entity.Company;
import com.jk.entity.CompanyRecord;
import com.jk.entity.Transaction;
import com.jk.entity.TransferRecord;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface  CompanyMapper {

    @Select("select * from company t where t.userId = #{userId}")
    //property实体类中的属性，column对应数据库中的字段名，@Results相当于resultMap
    @Results({
            @Result(property = "companyId",column = "companyId"),
            @Result(property = "companyName",column = "companyName"),
            @Result(property = "companyArea",column = "companyArea"),
            @Result(property = "companyAccount",column = "companyAccount"),
            @Result(property = "companyDate",column = "companyDate"),
            @Result(property = "userId",column = "userId")
    })
    public List<Company> queryCompany(String userId);

    @Insert("insert into company values(#{companyId},#{companyName},#{companyArea},#{companyAccount},#{companyDate},#{userId}) ")
    public List<Company> addCompany(Company company);


    @Delete("delete from company where companyId=#{companyId}")
    boolean deleteCompany(String companyId);



    /**查询交易记录*/
    @Select("select * from company_record t where t.userId = #{userId}")
    @Results({
            @Result(property ="id",column = "id"),
            @Result(property ="recordName",column = "recordName"),
            @Result(property ="dealMoney",column = "dealMoney"),
            @Result(property ="dealStatus",column = "dealStatus"),
            @Result(property ="dealDate",column = "dealDate"),
            @Result(property ="userId",column = "userId")
    })
    List<CompanyRecord> selectJyjl(String userId);

    /**查询商铺余额*/
    @Select("select SUM(t.companyAccount) from company t where t.userId = #{userId}")

   Long selectSpye(String userId);
}
